package com.shark.uh.annotation;

import com.shark.uh.annotation.validator.EnumCheckValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target({ElementType.FIELD, ElementType.PARAMETER}) // 适用于字段和方法参数
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = {EnumCheckValidator.class}) // 自定义验证器
public @interface EnumCheck {
    String message() default "枚举中不存在该值。";

    Class<? extends Enum<?>> enumClass();

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}
